package com.bfxy.rabbit.api.model;

import com.bfxy.rabbit.api.enums.MessageTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Message implements Serializable {

    private static final long serialVersionUID = -1L;

    /**
     * 消息的唯一ID
     */
    private String messageId;
    /**
     * 消息的主题（即RabbitMQ中的exchange概念）
     */
    private String topic;
    /**
     * 消息的路由规则
     */
    private String routingKey = "";
    /**
     * 消息的附加属性
     */
    private Map<String, Object> attributes = new HashMap<>();
    /**
     * 延迟消息的参数配置
     */
    private Integer delayMills;
    /**
     * 消息类型，默认为CONFIRM类型
     */
    private MessageTypeEnum messageType = MessageTypeEnum.CONFIRM;

    public Message(String messageId, String topic, String routingKey, Map<String, Object> attributes, Integer delayMills) {
        this.messageId = messageId;
        this.topic = topic;
        this.routingKey = routingKey;
        this.attributes = attributes;
        this.delayMills = delayMills;
    }
}
